﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NBusiness.Data
{
    /// <summary>
    /// The persistence guard prevents an object from being persisted more than once by
    /// its relationships. It is done this way so that if there is an exception the
    /// persistence guard will be turned off when Dispose is called. Otherwise an object
    /// would no longer be able to persist for its lifetime.
    /// </summary>
    [Serializable]
    internal class PersistenceGuard : IDisposable
    {
        bool _persisting = true;

        public bool Persisting
        {
            get { return _persisting; }
        }

        #region IDisposable Members

        public void Dispose()
        {
            _persisting = false;
        }

        #endregion
    }
}
